/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package simcreature;
import java.io.*;
import java.util.*;
/**
 *
 * @author bloc1dav
 */
public class FileWriter {
    public void saveState(Properties props,List<Creature> creatures, String Filepath){
        for(int i = 0; i<creatures.size(); i++){
            Creature creature = creatures.get(i);
            props.setProperty("Creature.Name-"+i,String.valueOf(creature.getLName()));
            props.setProperty("Creature.X-"+i,String.valueOf(creature.getX()));
            props.setProperty("Creature.Y-"+i,String.valueOf(creature.getY()));
            props.setProperty("Creature.Health-"+i,String.valueOf(creature.getMaxHealth()));
            props.setProperty("Creature.Type-"+i,String.valueOf(creature.getType()));
            props.setProperty("Creature.Behavior-"+i,String.valueOf(creature.getBehavior()));
            props.setProperty("Creature.Size-"+i,String.valueOf(creature.getSize()));
            props.setProperty("Creature.Strength-"+i,String.valueOf(creature.getStrength()));
            props.setProperty("Creature.Speed-"+i,String.valueOf(creature.getSpeed()));
            props.setProperty("Creature.canGroup-"+i,String.valueOf(creature.getCanGroup()));
            props.setProperty("Creature.canCannibalize-"+i,String.valueOf(creature.getCanCannibalize()));

        }
        try{
            props.store(new FileOutputStream(Filepath),
            "Creature information");
            //props.storeToXML(newFileOutputStream(“animalSim.properties”),
            // ”animal information”);
        }catch(IOException e){
            e.printStackTrace();
        }
    }
}
